import { createCrudApi } from '@/utils/apiFactory';
import request from '@/utils/unirequest';
import type { IResult } from '@/type/common';
import type {
  ISysHrResignRequestBill,
  ISysHrResignRequestBillView,
  ISysHrResignRequestBillVm,
  ISysPersonSearchQuery,
  ISysPersonSearchResponse
} from './interface';

export default function SysHrResignRequestBillApi() {
  // 基础CRUD用工厂生成
  const baseCrud = createCrudApi<
    ISysHrResignRequestBillView,
    ISysHrResignRequestBillVm,
    ISysHrResignRequestBill
  >('/api/SysHrResignRequestBill');

  return {
    ...baseCrud,
    // 额外的特殊接口
    // 获取单据编号接口
    async getBillCode(): Promise<IResult<string>> {
      return await request.get('/api/SysHrResignRequestBill/PredictCode');
    },
    // 审核接口
    async approve(data: ISysHrResignRequestBillVm): Promise<ISysHrResignRequestBill> {
      return await request.post('/api/SysHrResignRequestBill/approve?tag=', data);
    },
    // 员工搜索接口
    async searchPersons(query: ISysPersonSearchQuery): Promise<ISysPersonSearchResponse> {
      return await request.post('/api/SysPerson/Search', query);
    },
  };
}